package com.huahua.api.entity.framework;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Map;

/**
 * @author Huahua-Ai
 * @date 2025-07-24 16:50:00
 * @description MQTT请求消息格式
 */
@Data
@Accessors(chain = true)
public class MqttRequest {

    /**
     * 命令类型（驼峰命名）
     * print, cancelJob, getJobStatus, getPrinterStatus, listPrinters, getSystemStatus
     */
    private String command;

    /**
     * 请求ID
     */
    private String requestId;

    /**
     * 请求参数
     */
    private Map<String, Object> params;

    /**
     * 创建打印请求
     */
    public static MqttRequest createPrintRequest(String requestId, Map<String, Object> params) {
        return new MqttRequest()
                .setCommand("print")
                .setRequestId(requestId)
                .setParams(params);
    }

    /**
     * 创建取消任务请求
     */
    public static MqttRequest createCancelJobRequest(String requestId, String jobId) {
        return new MqttRequest()
                .setCommand("cancelJob")
                .setRequestId(requestId)
                .setParams(Map.of("jobId", jobId));
    }

    /**
     * 创建获取任务状态请求
     */
    public static MqttRequest createGetJobStatusRequest(String requestId, String jobId) {
        return new MqttRequest()
                .setCommand("getJobStatus")
                .setRequestId(requestId)
                .setParams(Map.of("jobId", jobId));
    }

    /**
     * 创建获取打印机状态请求
     */
    public static MqttRequest createGetPrinterStatusRequest(String requestId, String printerName) {
        return new MqttRequest()
                .setCommand("getPrinterStatus")
                .setRequestId(requestId)
                .setParams(Map.of("printerName", printerName));
    }

    /**
     * 创建列出打印机请求
     */
    public static MqttRequest createListPrintersRequest(String requestId) {
        return new MqttRequest()
                .setCommand("listPrinters")
                .setRequestId(requestId)
                .setParams(Map.of());
    }

    /**
     * 创建获取系统状态请求
     */
    public static MqttRequest createGetSystemStatusRequest(String requestId) {
        return new MqttRequest()
                .setCommand("getSystemStatus")
                .setRequestId(requestId)
                .setParams(Map.of());
    }
}
